<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page session="true"%>
<%@ page import="javax.portlet.*"%>
<%@ page import="pits.dto.PreSearchDTO"%>
<%@ page import="pits.dao.SearchInfoDAO"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<portlet:defineObjects />

<html>

<script>
	function getForm(namespace, name) {
        return document.forms[namespace + name];
    }

    function submitForm(namespace, name, action, page) {
        var frm = getForm(namespace, name);
        frm.txtAction.value = action;
        frm.submitLink.value = page;
        frm.submit();
    }
</script>

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Personal Information Tracking System</title>
<meta name="keywords" content="" />
<meta name="description" content="" />

<script type="text/javascript"
	src='<%=renderRequest.getContextPath() + "simpletreemenu.js" %>'>
/***********************************************
* Simple Tree Menu- Â© Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<link rel="stylesheet" type="text/css" href="style/simpletree.css" />

<script type="text/javascript"
	src='<%=renderRequest.getContextPath() + "/js/calendarDateInput.js" %>'>

/***********************************************
* Jason's Date Input Calendar- By Jason Moon http://calendar.moonscript.com/dateinput.cfm
* Script featured on and available at http://www.dynamicdrive.com
* Keep this notice intact for use.
***********************************************/

</script>

<link href="style/style.css" rel="stylesheet" type="text/css"
	media="screen" />
</head>

<body>
<form name="<portlet:namespace/>myForm" action="<portlet:actionURL/>"
	method="POST"><input type="hidden" name="txtAction" /> <input
	type="hidden" name="submitLink" /> <%
	PreSearchDTO preSearchData = new SearchInfoDAO().getData();
%>
<p align="right">You are logging in as <a href="#"
	onclick="submitForm('<portlet:namespace/>', 'myForm', 
									'home', 'AddTakenCompanyInfo.jsp')">
<b>${sessionScope.userName}</b></a> ! &nbsp; <a href="#"
	onclick="submitForm('<portlet:namespace/>', 'myForm', 
									'logout', 'AddTakenCompanyInfo.jsp')">
Logout</a></p>
</form>
<form name="<portlet:namespace/>addTakenCompanyInfoForm"
	action="<portlet:actionURL/>" method="POST"><input type="hidden"
	name="txtAction" /> <input type="hidden" name="submitLink" />
<table align="center">
	<tr class="title">
		<td colspan="2">
		<h1><a href="#">Personal information tracking system </a></h1>
		<p>exploit the value of data</p>
		<hr />
		</td>
	</tr>

	<tr>
		<td>
		<table border="1">
			<tr>
				<td>
				<h4 align="center" style="color: #FF0000">${sessionScope.successMess}
				${sessionScope.errorMess}</h4>
				</td>
			</tr>
			<tr>
				<td>
				<h2 class="title">Experience Information</h2>
				</td>
			</tr>
			<tr>
				<td>
				<table border="1" width="100%">
					<tr>
						<td align="left" valign="bottom">&nbsp;Company</td>
						<td align="left" valign="middle"><select id="comSelect"
							onchange="
									for (k = 0; k < '<%=preSearchData.getCompanyNames().size() %>'; k++) {
										document.getElementById(k).style.display='none';
									}
									document.getElementById(this.selectedIndex).style.display = 'inline';
									comSelected = this.selectedIndex;
								">
							<%
								for (int i = 0; i < preSearchData.getCompanyNames().size(); i++) {
								%>
							<option value=<%=preSearchData.getCompanyNames().get(i) %>><%=preSearchData.getCompanyNames().get(i) %></option>
							<%
								}
								%>
						</select></td>
					</tr>
					<tr>
						<td>&nbsp;Department&nbsp;</td>
						<td colspan="2" align="left" valign="middle"><input
							type="hidden" name="txtDepartment" /> <%
									for (int i = 0; i < preSearchData.getCompanyNames().size(); i++) {
										String dis = new String("none");
										if (i == 0) dis = "inline";
									%>
						<div id='<%=i %>'
							style='<%="position:relative; display:" + dis %>'><select
							id='<%="dep" + i %>'
							onchange="this.form.txtDepartment.value = this.value;
										">
							<option value="">&nbsp;</option>
							<%
										for (int j = 0; j < preSearchData.getDepartNames().get(i).size(); j++) {
									%>
							<option value=<%=preSearchData.getDepartIDs().get(i).get(j) %>><%=preSearchData.getDepartNames().get(i).get(j) %></option>
							<%
										}
									%>
						</select></div>
						<%
									}
									%>
						</td>
					</tr>
					<tr>
						<td align="left" valign="middle" rowspan="2">&nbsp;Working
						Period&nbsp;</td>
						<td align="left" valign="middle">From</td>
						<td align="center" valign="middle">&nbsp; <script>
										DateInput('txtStartDate', true, 'DD-MM-YYYY', '<%= request.getContextPath() %>');
									</script></td>
					</tr>
					<tr>
						<td align="left" valign="middle">&nbsp;To&nbsp;</td>
						<td align="center" valign="bottom">&nbsp; <script>
										DateInput('txtEndDate', true, 'DD-MM-YYYY', '<%= request.getContextPath() %>');
									</script></td>
					</tr>
					<tr>
						<td align="left" valign="middle">&nbsp;Role&nbsp;</td>
						<td><textarea name="txtRole" rows="1"></textarea></td>
						<td align="left" valign="top"><select name="selectRole"
							onchange="if(this.value=='Other'){
														this.form.otherRole.style.visibility='visible';
														this.form.otherRole.focus();}
												else{this.form.otherRole.style.visibility='hidden';}">
							<c:forEach items="${sessionScope.roles}" var="role">
								<option id="role${role.roleID}" value="${role.role}">${role.role}</option>
							</c:forEach>
							<option value="Other">Other</option>
						</select> <input name="otherRole" type="text" style="visibility: hidden" />
						<input type="button" value="Add"
							onclick="
									  				if (this.form.txtRole.value=='') {
										  				if (this.form.selectRole.value!='Other') {
											  				this.form.txtRole.value = this.form.selectRole.value;
										  				} else {
											  				this.form.txtRole.value = this.form.otherRole.value;
										  				}
									  				}
													" />
						&nbsp;<input type="button" value="Clear"
							onclick="
													this.form.txtRole.value='';
									" />
						</td>

					</tr>
					<tr>
						<td>More Description</td>
						<td align="left" valign="top" colspan="2"><textarea
							name="txtDescription" rows="2"></textarea></td>
					</tr>

					<tr align="left" valign="bottom">
						<td colspan="3"><input type="button" value=" Add  "
							onclick="submitForm('<portlet:namespace/>', 'addTakenCompanyInfoForm',
						  	  					'confirm', 'AddTakenCompanyInfo.jsp')" />
						<input type="button" value=" Back "
							onclick="submitForm('<portlet:namespace/>', 'addTakenCompanyInfoForm',
						  	  					'cancel', 'AddTakenCompanyInfo.jsp')" />
						</td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td colspan="2">
		<div style="clear: both;">&nbsp;</div>
		<div id="footer">
		<p>Development by HCMUT Project 1 Group 4 Spring 2010</p>
		</div>
		</td>
	</tr>
</table>
</form>
</body>

</html>